<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page language="java" import="com.limao.Tool.CacheClass"%>
<%@ page language="java" import="com.limao.CacheManager.AdvInfo"%>
<%@include file="/pc/jsp/common/common.jsp"%>

<%
    float authRmb=AdvInfo.CompanyAuthRmbParm();
%>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <title>成为供应商-企业</title>
    <link rel="stylesheet" href="js/validation/screen.css" />
    <script src="js/validation/jquery.js"></script>
    <script src="js/validation/jquery.validate.js"></script>
    <script src="js/validation/messages_zh.js"></script>
    
    <script src="js/ajaxfileupload.js"></script>
    <script>
		$(window).load(function() {
			headertabcurrent=5;
			$("#header").load("pc/header.jsp"); 
			$("#footer").load("pc/footer.jsp"); 
		});
	</script>
    <style>
                p.error{
                    color:#f51010;
                    font-size:12px;
                    margin-left:170px;
                 }
   </style>
</head>
<body  ontouchstart="">
    <!--header-->
	<div  id="header"> </div>
    

    <div class="container jz" style="margin-top: 18px;">
    <form  method="post" id="signupForm" action="" >
        <div class="w100 of bcf">
            <div class="fqzcTittle jz of clearfix">
                <div class="fl f20 c3">
                    供应商认证<span class="f16 c9" style="margin-left: 20px">已认证者，请登陆管理后台操作</span>
                </div>
                <div class="fr f16 c9">
                    供应商企业认，手续费<sapn class="cred"><%=authRmb%></sapn>元
                </div>
            </div><!--fqzcTittle-->
            <div class="w100 of">
                <div class="ishenqing jz of">
                    <p class="c3 f20 fw400" style="margin:36px auto 30px;">企业验证信息（必须填写真实企业有效资料）</p>
                    <div class="zcDiv clearfix of">
                        <label for="IDcard" class="IDcard f18 fl"><img src="pc/images/xing.png" class="xing dib pr">企业名称</label>
                        <input type="text" name="companyname" id="companyname" class="zcInput fr"/>
                    </div>
                    <div class="zcDiv clearfix of">
                        <label for="IDname" class="IDcard f18 fl"><img src="pc/images/xing.png" class="xing dib pr">执照证号</label>
                        <input type="text" name="companyno" id="companyno" class="zcInput fr"/>
                    </div>
                    <div class="zcDiv clearfix of pr">
                        <label for="zhizhao" class="IDcard f18 fl"><img src="pc/images/xing.png" class="xing dib pr">营业执照</label>
                        <div class="zhizhao db tc f16 fw700 ffa fl cursor pr of" id="companycard" onclick="triggerFile($('#companycardFile'));">
                            +
                            <div  id="companycardViewImg" class="viewImg">
                            </div>
                        </div>
                        <input type="hidden" value="" id="companycardImg" name="companycardImg">
                        <input type="file" value="" id="companycardFile" name="companycardFile" class="zhizhaoImgInput" class="required" accept="image/*" onchange="showPic('companycardFile',$('#companycardViewImg'),'companycardImg');"/>
                    </div>
                    <p class="cred f15 mgt10" style="margin-left: 147px">注：营业执照正面，字迹清晰可见</p>
                   
					<div class="zcDiv clearfix of">
                        <label for="zhizhao" class="IDcard f18 fl"><img src="pc/images/xing.png" class="xing dib pr">显示用logo</label>
                        <div class="zhizhao  db tc f16 fw700 ffa fl cursor pr of" id="compaylogo" onclick="triggerFile($('#compaylogoFile'));">
                            +
                            <div id="companylogoViewImg" class="viewImg">
                            </div>
                        </div>
                       	<input type="hidden" value="" id="companylogoImg" name="companylogoImg">
                        <input type="file" value="" id="compaylogoFile" name="compaylogoFile" class="zhizhaoImgInput" class="required" accept="image/*" onchange="showPic('compaylogoFile',$('#companylogoViewImg'),'companylogoImg');"/>
                    </div>  
                    
					<p class="c3 f20 fw400" style="margin:36px auto 30px;">法人信息（必须填写法人真实有效资料）</p>
                    <div class="zcDiv clearfix of">
                        <label for="IDname" class="IDcard f18 fl"><img src="pc/images/xing.png" class="xing dib pr">法人姓名</label>
                        <input type="text" name="IDname" id="IDname" class="zcInput fr" />
                        <p class="t2 cred f14"></p>
                    </div>                 
                    <div class="zcDiv clearfix of">
                        <label for="IDcard" class="IDcard f18 fl"><img src="pc/images/xing.png" class="xing dib pr">法人身份证号码</label>
                        <input type="text" name="IDcard" id="IDcard" class="zcInput fr" maxlength="40" />
                    </div>
                    <div class="zcDiv clearfix of">
                        <label for="zhizhao" class="IDcard f18 fl"><img src="pc/images/xing.png" class="xing dib pr">法人身份证相片</label>
                        <div class="zhizhao  db tc f16 fw700 ffa fl cursor pr of" style="margin-left: 50px;" id="manNo1" onclick="triggerFile($('#manNoFile1'));">
                            +<span style="font-size: 24px;margin-left: 10px">正面</span>
                            <div id="manNoViewImg1" class="viewImg">
                            </div>
                        </div>
                        <input type="hidden" value="" id="manNoImg1" name="manNoImg1">
                        <input type="file" value="" id="manNoFile1" name="manNoFile1" class="zhizhaoImgInput" class="required" accept="image/*" onchange="showPic('manNoFile1',$('#manNoViewImg1'),'manNoImg1');"/>

                        <div class="zhizhao  db tc f16 fw700 ffa fl cursor pr of" style="margin-left: 50px;" id="manNo2" onclick="triggerFile($('#manNoFile2'));">
                            +<span style="font-size: 24px;margin-left: 10px">反面</span>
                            <div id="manNoViewImg2" class="viewImg">
                            </div>
                        </div>
                        <input type="hidden" value="" id="manNoImg2" name="manNoImg2">
                        <input type="file" value="" id="manNoFile2" name="manNoFile2" class="zhizhaoImgInput" class="required" accept="image/*" onchange="showPic('manNoFile2',$('#manNoViewImg2'),'manNoImg2');"/>
                        
                    </div>

					                  
                    
                    <script>
                        function triggerFile(file) {
                            var file = file;
                            file.trigger('click');
                        }
                        function showPic(fileURL,imgDiv,cardImg) 
                        {
	                         $.ajaxFileUpload({  
				                 url:"upload",    //需要链接到服务器地址  
				                 type: 'post',         
				                 secureuri:false,  
				                 fileElementId:''+fileURL,                      //文件选择框的id属性  
				                 dataType: 'json',                             //服务器返回的格式，可以是json  
				                 success: function (data)             //相当于java中try语句块的用法  
				                 {  
				                 	if(data['state']==1)
				                 	{
	 		                            var img = '<img src='+imgBaseUrl+data.URLList.IMAGE0+'>';
			                            imgDiv.html(img);
			                            $('#'+cardImg).val(data.URLList.IMAGE0);
				                 	}
				                 	else
				                 	{
				                 	  layer.alert(data.info);
				                 	  $('#'+cardImg).val("");
				                 	}
				                 },  
				                 error: function (data)             //相当于java中catch语句块的用法  
				                 {  
				                 	$('#'+cardImg).val("");
				                 }  
				               }  
				             );  
                        }
                    </script>


                    <p class="c3 f20 fw400" style="margin:36px auto 30px;">企业信息（必须填写真实有效资料）</p>
                    <div class="zcDiv clearfix of">
                        <label for="city_3" class="IDcard f18 fl"><img src="pc/images/xing.png" class="xing dib pr">所在地</label>
                        <div id="city_3" class="fr">
                            <div class="w100 of clearfix">
                                <div class="fl f16">
                                    <select class="prov" id="prov" name="prov" required="required"></select>&nbsp;(省份)
                                </div>
                                <div class="fr f16" style="margin-left: 38px">
                                    <select class="city" id="city" name="city" disabled="disabled" required="required"></select>&nbsp;(城市)
                                </div>
                            </div>
                        </div> <!--city_3-->
                        <script src="js/jquery.cityselect.js"></script>
                        <script>
                            $(function () {
                                $("#city_3").citySelect({required: false});
                            })
                        </script>
                    </div>
                    <div class="zcDiv clearfix of">
                        <input type="text" name="detailAddress" id="detailAddress" class="zcInput fr" placeholder="详细地址"/>
                    </div>

                    <p class="c3 f20 fw400" style="margin:36px auto 30px;">企业信息（必须填写真实有效资料）</p>
                    <div class="zcDiv clearfix of">
                        <label for="username" class="IDcard f18 fl"><img src="pc/images/xing.png" class="xing dib pr">认证人联系人</label>
                        <input type="text" name="username" id="username" class="zcInput fr" placeholder="真实姓名"/>
                    </div>
                    <div class="zcDiv clearfix of">
                        <input type="text" name="usertel" id="usertel" class="zcInput fr" placeholder="联系电话"/>
                    </div>
                    <div class="zcDiv clearfix of">
                        <input type="text" name="qq" id="qq" class="zcInput fr" placeholder="QQ/微信"/>
                    </div>




                    <p class="c3 f20 fw400" style="margin:60px auto 24px;">缴纳企业认证手续费</p>
                    <p class="corange fw600" style="font-size: 40px;margin-left: 202px;"><%=authRmb%><sapn style="font-size: 35px;">00</sapn></p>
                    <p class="c6 f18 fw400" style="margin:35px auto 15px;">选择支付方式</p>
                    <div class="clearfix of w100">
                        <input type="radio" id="zhifubao" checked="checked" name="payment" value="zhifubao">
                        <label name="zhifubao" class="labelR checked" for="zhifubao">支付宝</label>
                        <input type="radio" id="wexin" name="payment" value="wexin">
                        <label name="wexin"class="labelR" for="wexin">微信</label>
                        <input type="radio" id="xianxia" name="payment" value="xianxia">
                        <label name="xianxia" class="labelR" for="xianxia" style="margin-right: 0;">线下付款</label>
                    </div>
                    <div id="xianxiaDiv" class="zcDiv of w100">
                        <div class="zhizhao jz db tc f16 fw700 ffa cursor pr of" id="pay" style="margin-left: 225px" onclick="triggerFile($('#payFile'));">
                            +
                            <div id="payviewImg" class="viewImg">
                            </div>
                        </div>
                         <input type="hidden" value="" id="payImg" name="payImg">
                        <input type="file" value="" id="payFile" name="payFile" class="zhizhaoImgInput" onchange="showPic('payFile',$('#payviewImg'),'payImg');"/>
                        <p class="c9 f12 tc db mgt10 lh2">点击上传线下付款凭证图</p>
                    </div>
                    <div class="zcDiv w100">
                        <input type="button" name="" id="" value="提交申请"  id="fqztSub" class="fqztSub blueh cursor db jz cf tc f20" onclick="Sub();" />
                    </div>

                    <script>
                        $(function() {
                        	
                        
                            $('.labelR').click(function(){
                                var current =$(this);
                                var currentId = $(this).attr('name');
                                $('.labelR').removeClass('checked');
                                current.addClass('checked');
                                $('input[name="payment"]').removeAttr('checked') && current.prev('input[name="payment"]').attr('checked', 'checked');
//                                $('input[name="payment"]:checked').val();

                                var payWay = $('label.checked').text();
                                if(payWay=='支付宝')
	                            {
	                            	paywayVal=0;
	                            }
	                            else if(payWay=='微信')
	                            {
	                            	paywayVal=1;
	                            }
	                            else if(payWay=='线下付款')
	                            {
	                            	paywayVal=2;
	                            }
	                            console.log(currentId);
                                if(currentId=='xianxia'){
                                   $("#xianxiaDiv").slideDown();
                                }else {
                                    $("#xianxiaDiv").slideUp();

                                }
                            });
                        });
                    </script>
                </div><!--ishenqing-->
            </div>
        </div>
    </form>
    </div><!--container-->
    
	<!--footer-->
    <div id="footer" class="footer w100 of"></div>
    <div class="theme-popover-mask"></div>
   <div id="successSub" class="w100 h100 pf">
       <div class="jz of bcf">
            <div class="sqtittle tc jz c3">
                申请提交成功
            </div>
           <p class="successSubP f18 t2">
               您的认证申请已经提交，工作人员在三个工作日对资料进行审核，期间
               请保持通讯顺畅。
           </p>
           <button class="successSubBtn cf tc jz db blueh" onclick="successSubHide();">关闭</button>
       </div>
   </div><!--successSub-->

</body>
<script>
var paywayVal=2;
var myValidator;
$().ready(function() {
	 	  myValidator=$("#signupForm").validate(
	 		{
	 			rules:{
	 				
	 				companyname:{
	 					required: true,
                		rangelength:[8,50]
  	 				},
 			
	 				companycardImg:{
	 					required: true
  	 				}
  	 				/*   	 				
	 				companyno:{
	 					required: true,
                		rangelength:[8,25]
  	 				},		
 	 				companylogoViewImg:{
	 					required: true
  	 				}, 	 				 			
	 				IDcard:{
	 					required: true,
                		isIdCardNo:true 
  	 				},
	 				IDname:{
	 					required: true,
                		rangelength:[2,15] 
  	 				},	 
  	 				
	 				manNoImg1:{
	 					required: true
  	 				},
	 				manNoImg2:{
	 					required: true
  	 				},	  	 				
  	 				prov: {
                		required:true,
                		isShengcity:true
            		},			
  	 				city: {
                		required:true,
                		isShengcity:true
            		},
            		detailAddress:{
            			required:true,
             			rangelength:[5,50] 
            		},
            		username:
            		{
            			required:true,
            			rangelength:[2,15]
            		},
            		usertel:
            		{
            			required:true,
            			digits:true,	 			
	 				} */
	 			},
	 			//errorElement: 'p',
                errorPlacement: function(error, element) {
                // Append error within linked label
                
                $( element )
	                .closest( "form" )
	                .find( element )
	                .parent("div")
	                .after( error );
                },
                errorElement: "p"
				
	 		});
	 		
	 		
	 		
	 		
	 		
	 		
});

    function successSubHide() {
        $(".theme-popover-mask").fadeOut();
        $("#successSub").slideUp();
    }

    function proEstimate() {
        var provVal =$.trim($(".prov").find("option:selected").val());
        var cityVal =$.trim($(".city").find("option:selected").val());
        if(!(provVal == "请选择")&&!(cityVal == "请选择")){
            var info={"prov":provVal,"city":cityVal};
            return info;
        }else{

            return false;
        }
    }

    function Sub() {
        
        if(myValidator.form()== false){
            layer.alert("填写存在错误 ！");
            return false;
        }
        
        var companynameVal =$.trim($('#companyname').val());
        var companynoVal =$.trim($('#companyno').val());
        var companycardimgVal =$.trim($('#companylogoImg').val());
        
        var IDnameVal =$.trim($('#IDname').val());
        var IDcardVal =$.trim($('#IDcard').val());
        var zhizhaoImg1Val =$.trim($('#manNoImg1').val());
        var zhizhaoImg2Val =$.trim($('#manNoImg2').val());
        var logoVal =$.trim($('#companylogoImg').val());
        
        
     	var provVal =$.trim($(".prov").find("option:selected").val());
        var cityVal =$.trim($(".city").find("option:selected").val());
        var detailAddress = $.trim($('#detailAddress').val());
        detailAddress=provVal+cityVal+detailAddress;
        var usernameVal =$.trim($('#username').val());
        var usertelVal = $.trim($('#usertel').val());

        var zhizhaoImg3Val =$.trim($('#payImg').val());
        var qqVal = $.trim($('#qq').val());
        if(paywayVal!=2)
        {
        	layer.alert("暂不支持，请选择线下付款  进行测试。");
        }  
        $.ajax({
                url: "PlugServlet",
                data: JSON.stringify({m:1610,iscompany:1,companylogo:logoVal,companyname:companynameVal,companyno:companynoVal,companycardimg:companycardimgVal,companyman:IDnameVal,mancardno:IDcardVal,mancardimg0:zhizhaoImg1Val,mancardimg1:zhizhaoImg2Val,address:detailAddress,tel:usertelVal,telman:usernameVal,paytype:paywayVal,payimage:zhizhaoImg3Val,qq:qqVal}),
                type: 'post',
                dataType: 'json',
                contentType:"application/json;charset=utf-8",
                beforeSend: function () {
                    $(".theme-popover-mask").fadeIn();
                    $("#successSub").fadeIn();
                },
                success: function (data) {
                    console.log(data);
	             	if(data['state']==1)
						layer.alert(data.info);
					 else
					  	layer.alert(data.info);
                },
                error: function (data) {
                    return false;
                },
                complete: function () {
                    $(".theme-popover-mask").fadeOut();
                    $("#successSub").fadeOut();
                }
            });
        }

</script>

</html>